package com.example.app2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Activity_list2_item extends AppCompatActivity {
    TextView textView;
    EditText edit;
    Button btn,btn2;

    String coin;
    Float rate;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list2_item);

        textView = findViewById(R.id.item_rate);
        edit = findViewById(R.id.put_in);
        btn = findViewById(R.id.button10);
        btn2 = findViewById(R.id.button12);

        Intent re = getIntent();
        coin = re.getStringExtra("money");
        rate = re.getFloatExtra("rate",0.0f);

        textView.setText(coin);
    }

    public void btn12(View v){
        Intent back = new Intent(this,ActivityList2.class);
        startActivity(back);
    }

    public void btn10(View v){
        fun(rate,coin);
    }

    public void fun(Float rate2,String mon){
        String r = edit.getText().toString();
        if (r != null && r.length()>0){
            double rm = Float.parseFloat(r);
            double money = rm/rate2;
            edit.setText(String.valueOf(money)+mon);
        }else{
            edit.setText("未输入");
        }
    }


}